package com.uuah.server.lifecycle;

import com.uuah.server.api.IUuahContext;
import com.uuah.server.context.notification.ServerNotification;
import com.uuah.utils.ClassUtils;

/**
 *
 * TODO comment ...
 *
 * <p>
 * update record:updator，update time，update content and version
 * </p>
 *
 * @author <a href="jonny_quan@hotmail.com">jonny</a>
 * @date 2009 2009-3-27 下午01:52:06
 * @version 1.0.0
 */
public class LifecycleObject {

	private Class type;
	private ServerNotification preNotification;
	private ServerNotification postNotification;

	public LifecycleObject(Class type) {
		this.type = type;
	}

	public ServerNotification getPostNotification() {
		return postNotification;
	}

	public void setPostNotification(ServerNotification postNotification) {
		this.postNotification = postNotification;
	}

	public ServerNotification getPreNotification() {
		return preNotification;
	}

	public void setPreNotification(ServerNotification preNotification) {
		this.preNotification = preNotification;
	}

	public Class getType() {
		return type;
	}

	public void setType(Class type) {
		this.type = type;
	}

	public void firePreNotification(IUuahContext context) {
		if (preNotification != null) {
			context.fireNotification(preNotification);
		}
	}

	public void firePostNotification(IUuahContext context) {
		if (postNotification != null) {
			context.fireNotification(postNotification);
		}
	}

	// @Override
	public String toString() {
		return super.toString() + " (" + ClassUtils.getSimpleName(type) + ")";
	}

}